package com.xyyl.csc.controller;

import com.alibaba.fastjson2.JSONObject;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @PROJECT_NAME: springcloud-study
 * @DESCRIPTION:
 * @Author: csc
 * @DATE: 2023/4/8 16:46
 */
@RestController
public class TestController {

    public  int num = 0;

       @GetMapping("/test/hello")
       public  String  hello(){
           num =++num;
           return "发布成功我被访问了"+num+"次";
       }

    @PostMapping("/heartBeat")
    public  JSONObject  heartBeat(@RequestBody  String receive){
        System.out.println("心跳数据:"+1);
        JSONObject returnJson = new JSONObject();
        returnJson.put("result",1);
        returnJson.put("success",true);
        return returnJson;
    }


    @PostMapping("/Idcard")
    public  String  hello(@RequestBody  String receive){


        System.out.println("识别到的json数据:"+receive);
        return "发布成功我被访问了"+num+"次";
    }

    public static void main(String[] args) {
        ConcurrentHashMap map = new ConcurrentHashMap();
        map.put("csc","哈哈哈");
        map.put("name","奥特曼");
        System.out.println(map);

        HashMap hashMap = new HashMap();
        hashMap.put(null,"哈哈哈");
        hashMap.put("name","奥特曼");
        System.out.println(hashMap);
    }

}
